<?php
namespace app\admin\controller;

use think\App;
use think\facade\View;
use think\facade\Db;

class Member extends BaseController
{
    public function lists()
    {
        $list = Db::name('member')
            ->field('*')
            ->select();
        foreach($list as $val){
            echo $val['username'] . ' ';
            echo $val['nickname'] . ' ';
            echo $val['mobile'] . ' ';
            echo '</br>';
        }
    }

    public function add()
    {
        $data = [];
        for($i = 2000; $i < 10000;$i ++){
            $data[] = [
                'username' => $this->getName(4),
                'nickname' => $this->getName(2),
                'mobile' => '1583540'.$i,
                'password' => md5('123456'),
                'register_time' => time(),
            ];
        }
        $res = Db::name('member')->insertAll($data);
        dump($res);
    }

    public function getName($name_len)
    {
        $string = '赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯昝管卢莫经房裘缪干解应宗丁宣贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄曲家封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫';
        $length = mb_strlen($string);
        $name = '';
        for($i = 0; $i < $name_len; $i ++){
            $offset = rand(0, $length);
            $name .= mb_substr($string, $offset, 1);
        }
        return $name;
    }
}
